package xyz.zdsoft.course_manage_module.mapper;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import xyz.zdsoft.course_manage_module.vo.CourseInfoVo;
import xyz.zdsoft.course_manage_module.vo.CourseStudentInfoVo;

/**
 * @author 王林
 * @version 1.0
 * @date 2021-07-25 周日
 * @time 21:50
 * @description
 */
@Mapper
public interface TeacherCourseMapper extends BaseMapper {

    //    @Select({"<script>", "select id,project_date,course_name,remark,class_rome,sign_in_time,sign_out_time," +
//            "duty_teacher,train_teacher" +
//            " from course_info_view" +
//            "<if test=\"ew.sqlSegment != null and ew.sqlSegment != ''\">\n" +
//            "            where ${ew.sqlSegment}\n" +
//            "        </if>",
//            "</script>"})

    //    @Select("select *\n" +
//            "from tea_course_view tcv\n" +
//            "where tcv.teacher_id =#{teacherId} ")
    @Select({"<script>", "select id,project_date,course_name,duty_teacher,train_teacher," +
            "remark,class_rome,sign_in_time,sign_out_time " +
            " from tea_course_view\n" +
            "<if test=\"ew.sqlSegment != null and ew.sqlSegment != ''\">\n" +
            "where ${ew.sqlSegment}\n" +
            "        </if>",
            "</script>"})
    IPage<CourseInfoVo> queryAllCourse(IPage<CourseInfoVo> page,
                                       @Param("ew") Wrapper<CourseInfoVo> wrapper);

    //    @Select({"select student_name,user_no,id_no,sex,email,mobile_no,position," +
//            "colleges_name,major_name,grade_name,class_name,teacher_name,team_name,role_type" +
//            " from course_student_info_view vi" })
//            "from course_student_info_view vi where where cpi.id = 200"})
//    "where vi.class_info_id=#{courseId}"})
    @Select({"<script>","SELECT course_name,`student_name`,`team_name`,`colleges_name`,`major_name`," +
            "`grade_name`,`class_name`,`user_no`, `id_no`, `sex`, `email`," +
            " `mobile_no`,`position`,`class_teacher`" +
            "FROM course_student_info_view csiv where csiv.project_id = #{courseId}" +
            "<if test=\"ew.sqlSegment != null and ew.sqlSegment != ''\">\n" +
            "and ${ew.sqlSegment} \n" +
            "        </if>",
            "</script>"})
    IPage<CourseStudentInfoVo> queryCourseStudentInfo(IPage<CourseStudentInfoVo> page,
                                                      @Param("ew") Wrapper<CourseStudentInfoVo> wrapper,
                                                      @Param("courseId") Integer courseId);

}
